// 第一步，导入能导入的
import React, {
	Component
} from 'react';
import {
	HashRouter,
	Switch,
	Route,
	Redirect
} from 'react-router-dom';

// 第六步，导入组件
// 1.切记，要去配置文件里配置@
// 2.支持jsx，只需重启服务即可
import asyncComponent from '@/utils/asyncComponent';
import home from '@/pages/home/home'; //首页不需要按需加载
const cart = asyncComponent(() => import('@/pages/cart/cart'));
const category = asyncComponent(() => import('@/pages/category/category'));
const my = asyncComponent(() => import('@/pages/my/my'));
// import cart from '@/pages/cart/cart';
// import category from '@/pages/category/category';
// import my from '@/pages/my/my';

/**
 * 一级页面，二级页面
 * 页面内路由（前套路由）
 * 路由跳转按钮
 */


// 第二步，导出
export default class RouteConfig extends Component {
	// 第四步render函数
	render() {
		// 第五步return
		// 此处如同vue路由的定义文件
		return ( 
			<HashRouter>
        <Switch>
          <Route path="/" exact component={home} />
          <Route path="/home" component={home} />
          <Route path="/cart" component={cart} />
          <Route path="/category" component={category} />
					<Route path="/my" component={my} />
          <Redirect to="/" />
        </Switch>
      </HashRouter>
		)
	}
}
